package project.euler.honk.problem.to50;

final class Problem30 {

	public static void main(String[] args) {
		long start = System.currentTimeMillis();
		int sum = 0;
		for (int i = 0; i < 2; i++) {
			int tmp = i * i;
			int i_v = tmp * tmp * i;
			int i_t = 100000 * i;
			for (int j = 0; j < 10; j++) {
				tmp = j * j;
				int j_v = tmp * tmp * j;
				int j_t = 10000 * j;
				for (int k = 0; k < 10; k++) {
					tmp = k * k;
					int k_v = tmp * tmp * k;
					int k_t = 1000 * k;
					for (int l = 0; l < 10; l++) {
						tmp = l * l;
						int l_v = tmp * tmp * l;
						int l_t = 100 * l;
						for (int m = 0; m < 10; m++) {
							tmp = m * m;
							int m_v = tmp * tmp * m;
							int m_t = 10 * m;
							for (int n = 0; n < 10; n++) {
								tmp = n * n;
								int n_v = tmp * tmp * n;
								int number = i_t + j_t + k_t + l_t + m_t + n;
								int value = i_v + j_v + k_v + l_v + m_v + n_v;
								if (value == number) {
									sum += value; // Result: 443839 Time: 32
								}
							}
						}
					}
				}
			}
		}
		sum -= 1;
		long end = System.currentTimeMillis();
		System.out.println("Result: " + sum + " Time: " + (end - start));
	}

}
